***********************************************
* This do-file takes as input recoded dataset 
* \Mohanan_etal.dta, and outputs tables 
* reported in Mohanan et al. 2016
***********************************************

***********************************************
* Contents
***********************************************

	* (1.0) Set output location
	* (2.0) Main Regressions
	* (3.0) Robustness checks 

***********************************************
* (1.0) Set up a folder for your output
***********************************************

	global d_tab		/*FILL IN THIS GLOBAL MACRO WITH FOLDER FOR TABLE OUTPUT*/
	

*************************************************
* (2.0) Main Regressions
*************************************************
	use \Mohanan_etal.dta, clear 
	
	global controls1 		"mother_age mother_lit age_1 age_2 age_3 age_4 age_5 male " 
	global controls2 		"scstobc kids_0_5 hindu  BPL  wealth_2 wealth_3 wealth_4 wealth_5" 	
	global controls4 		"dist2-dist11_followup" 

	global outreg_options	`"excel alpha(0.01, 0.05, 0.10) stats(coef ci) bracket  dec(4)  symbol(***, **, *) nocons "' 

	
 foreach treatment of varlist   treatment_whp treatment_listing num_whp  { 

		local j = 1 
		rename `treatment' treat 


		local outcome diarrhea
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', replace ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
			

		foreach outcome in d_seekcare d_ors d_ors_self d_ors_provider {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 

			}

		local outcome d_ors_provider
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 		

		foreach outcome in d_zinc d_zinc_self d_zinc_provider {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
		
		}
	

		local outcome d_zinc_provider
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 

		foreach outcome in d_ors_zinc d_ors_zinc_self d_ors_zinc_provider {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
		}

		local outcome d_ors_zinc_provider
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
			
		local outcome d_oop
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if diarrhea==1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
	
		
		****************************************************

		local outcome pneumonia
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	

			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
		rename outcome `outcome' 

		foreach outcome in p_seekcare p_abx p_abx_full p_abx_self p_abx_self_full p_abx_provider p_abx_provider_full {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia==1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
		}

		
		foreach outcome in p_abx_provider p_abx_provider_full {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia==1 & p_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
		}		

		local outcome p_oop
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia==1 & p_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome'
			

		****************************************************

		local outcome pneumonia_cherg
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
		rename outcome `outcome' 

		foreach outcome in pc_seekcare pc_abx pc_abx_full pc_abx_self pc_abx_self_full pc_abx_provider pc_abx_provider_full {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia_cherg==1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 
		}
		

		foreach outcome in   pc_abx_provider pc_abx_provider_full {
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia_cherg==1 & pc_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome' 		
		}
		
		
			local outcome pc_oop
			rename `outcome' outcome	
			cap drop followup_treat
				gen followup_treat = followup * treat	
			xi: reg outcome followup treat followup_treat $controls1 $controls2 $controls4 if pneumonia_cherg==1 & pc_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			rename outcome `outcome'
		
		rename treat `treatment' 
		
		}

		


*************************************************
* (3.0) Robustness Checks
*************************************************

	global controls1 		"dist2-dist11_followup" 
	global controls2 		"male age_1 age_2 age_3 age_4 age_5 dist2-dist11_followup" 
	global controls3 		"male age_1 age_2 age_3 age_4 age_5  mother_lit mother_age dist2-dist11_followup" 
	global controls4 		"male age_1 age_2 age_3 age_4 age_5  mother_lit mother_age kids_0_5 hindu scstobc BPL wealth_2 wealth_3 wealth_4 wealth_5 dist2-dist11_followup" 
	
	foreach treatment of varlist   treatment_whp treatment_listing num_whp  { 
		local j = 1 
		rename `treatment' treat 


		local outcome diarrhea
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} , cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome' 

		foreach outcome in d_seekcare d_ors d_ors_self d_ors_provider {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  

			}

		local outcome d_ors_provider
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome' 
		

		foreach outcome in d_zinc d_zinc_self d_zinc_provider {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome' 
		
		}
	

		local outcome d_zinc_provider
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome' 

		foreach outcome in d_ors_zinc d_ors_zinc_self d_ors_zinc_provider {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome' 
		}

		local outcome d_ors_zinc_provider
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		
	
		local outcome d_oop
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if diarrhea == 1 & d_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		
	
		****************************************************

		local outcome pneumonia
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} , cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  

		foreach outcome in p_seekcare p_abx p_abx_full p_abx_self p_abx_self_full p_abx_provider p_abx_provider_full {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		}

		
		foreach outcome in p_abx_provider p_abx_provider_full {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia == 1 & p_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		}		
		
		local outcome p_oop
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia == 1 & p_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  

		****************************************************

		local outcome pneumonia_cherg
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} , cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'    

		foreach outcome in pc_seekcare pc_abx pc_abx_full pc_abx_self pc_abx_self_full pc_abx_provider pc_abx_provider_full {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia_cherg == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		}
		

		foreach outcome in   pc_abx_provider pc_abx_provider_full {
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia_cherg == 1 & pc_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  		
		}
	
		local outcome pc_oop
			rename `outcome' outcome
			cap drop followup_treat
				gen followup_treat = followup * treat	
			forval i = 1/4 { 
			xi: reg outcome followup treat followup_treat ${controls`i'} if pneumonia_cherg == 1 & pc_seekcare == 1, cluster(cluster)	
				outreg2  using `"$d_tab\Primary_outcomes_robustness_`treatment'_`c(current_date)'_district_year.xls"', append ctitle("`outcome' ") $outreg_options
			}
			rename outcome `outcome'  
		
		rename treat `treatment' 
		
		}


	